﻿import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:getx_scaffold/getx_scaffold.dart';
import 'firmware_info_logic.dart';

/// 固件信息页面
class FirmwareInfoView extends GetView<FirmwareInfoLogic> {
  const FirmwareInfoView({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor:  Colors.black,
      appBar: AppBar(
        backgroundColor: const Color(0xFF282528),
        elevation: 0,
        leading: GestureDetector(
          onTap: () => Get.back(),
          child: const Icon(
            Icons.arrow_back_ios,
            color: Colors.white,
            size: 20,
          ),
        ),
        title: const Text(
          '固件信息',
          style: TextStyle(
            color: Colors.white,
            fontSize: 18,
            fontWeight: FontWeight.w500,
          ),
        ),
        centerTitle: true,
      ),
      body: SingleChildScrollView(
        padding: EdgeInsets.all(24.w),
        child: Container(
          decoration: BoxDecoration(
            color: const Color(0xFF282528),
            borderRadius: BorderRadius.circular(28.r),
          ),
          child: Column(
            children: [
              Obx(() => _buildInfoItem('设备名称', controller.deviceName.value)),
              _buildDivider(),
              Obx(() => _buildInfoItem('颜色', controller.color.value)),
              _buildDivider(),
              Obx(() => _buildInfoItem('尺寸', controller.size.value)),
              _buildDivider(),
              Obx(() => _buildInfoItem('固件版本号', controller.firmwareVersion.value)),
              _buildDivider(),
              Obx(() => _buildInfoItem('MAC 地址', controller.macAddress.value)),
              _buildDivider(),
              Obx(() => _buildInfoItem('序列号', controller.serialNumber.value)),
            ],
          ),
        ),
      ),
    );
  }

  Widget _buildInfoItem(String title, String value) {
    return Container(
      height: 60.h,
      padding: EdgeInsets.symmetric(horizontal: 20.w),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          Text(
            title,
            style: TextStyle(
              color: Colors.white,
              fontSize: 16.sp,
            ),
          ),
          Expanded(
            child: Text(
              value,
              style: TextStyle(
                color: const Color(0xFF666666),
                fontSize: 14.sp,
              ),
              textAlign: TextAlign.right,
              overflow: TextOverflow.ellipsis,
            ),
          ),
        ],
      ),
    );
  }

  Widget _buildDivider() {
    return Divider(
      height: 1,
      thickness: 1,
      color: const Color(0xFF1A1A1A),
      indent: 20.w,
      endIndent: 20.w,
    );
  }
}
